#include "container/list.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


LIST_HEAD(head);
struct nameNode
{
    char name[32];
    struct list_head node;
};

int main() {
    struct  nameNode *n = (struct nameNode *)malloc(sizeof(struct nameNode));
    strcpy(n->name, "frist");
    list_add(&n->node, &head);
    n = (struct nameNode *)malloc(sizeof(struct nameNode));
    strcpy(n->name, "end");
    list_add_tail(&n->node, &head);

    struct  nameNode *p;
    struct list_head *item;
    list_for_each (item, &head) {
        p = list_entry(item, struct nameNode, node);
        printf("name:%s\n", p->name);
    }

    struct nameNode *tmp;
    list_for_each_entry_safe(p, tmp, &head, node) {
        list_del(&p->node);
        free(p);
    }
    return 0;
}


